<link rel="stylesheet" href="/static/bbs/css/admin.css?v=<?=env('version')?>">
<div class="alone-banner layui-bg-black" style="height:200px;">
  <div class="layui-main">
    <h1><?=$info['title']?></h1>
    <p><?=$info['description']?></p>
  </div>
</div>
<div class="layui-main alone-nav">
  <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
    <ul class="layui-tab-title">
      <li class="layui-this">
        <a href="javascript:;">快速使用</a>
      </li>
      <li>
        <?php if($info['pic']):?>
          <div id="tong" style="display:none;" ><img style="width:350px;height:350px;margin:10px;" src="<?=$info['pic']?>"></div>
          <a href="javascript:layer.open({title:'扫码查看',type:1,area:'370px',shadeClose:true,content:$('#tong')});" target="_blank">在线演示</a>
        <?php else:?>
          <a href="<?=$info['demo_url']?>" target="_blank">在线演示</a>
        <?php endif;?>
      </li>
      <li>
        <a href="<?=$patch['qun'][1]?>" target="_blank">联系客服</a>
      </li>
    </ul>
  </div>

  <div class="site-layim-title"><fieldset><legend>获取授权</legend></fieldset></div>
  <?php include_once __DIR__.'/'.$info['id'].'.html';?>
  <div class="site-layim-title"><fieldset><legend>说明</legend></fieldset></div>
  <div class="layui-text">
    <?=htmlspecialchars_decode($info['content'])?>
  </div>
</div>

<div id="qrcode" style="display:none;"><img src="" id="pay_img_url" /></div>


<script>
$(document).ready(function(){
  layui.use(['form', 'layedit', 'laydate'], function(){
    var form = layui.form
    ,layer = layui.layer
    ,layedit = layui.layedit
    ,laydate = layui.laydate;

    //支付二维码
    function getpay(year,price,id){
      var index = layer.load(0, {time: 10*1000});
      $.ajax({
        url:"<?=url('userxiangmu/pay')?>",
        method:'post',
        dataType:'json',
        data:{year:year,price:price,id:id},
        success:function(res){
          $("#pay_img_url").attr('src',res.data['url']);
          $("#pay_img_url").attr('order_no',res.data['order_no']);
          layer.open({
            type: 1,
            title: false,
            closeBtn: 0,
            area: '516px',
            skin: 'layui-layer-nobg',
            shadeClose: true,
            content: $('#qrcode')
          });
        },
        complete: function(){
            layer.close(index);
        }
      });
    }
    $(".site-layim-buy .layui-btn").click(function(){
      var year = $(this).attr('_year');
      var price = $(this).attr('_price');
      var id = $(this).attr('_id');
      getpay(year,price,id);
    });
    //轮询是否支付成功
    var interval = setInterval(function(){
      var order_no = $("#pay_img_url").attr('order_no');
      $.ajax({
        url:"<?=url('userxiangmu/querypay')?>",
        method:'post',
        dataType:'json',
        data:{order_no:order_no},
        success:function(res){
          if(res.code==0){
            clearInterval(interval);
            layer.msg('支付成功,跳转中...');
            window.location.href = res.data;
          }
        }
      });
    },1000);
  });
});
</script>
